<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>班次管理</title>
<jsp:include page="${home}/assets/common_inc_new.jsp"  flush="true"></jsp:include>
<script type="text/javascript" src="${home}/system/common/scripts/utils.js"></script>
<!-- <script type="text/javascript" src="/zhcy/zrf/utils.js"></script> -->
<link rel="stylesheet" type="text/css" href="./index.css">
<script type="text/javascript">
var result;
var page_current=1;
var page_size=0;
var page_interval=10;
//var id=window.setInterval(doCopy,5000);定时任务
function queryGrid(){

	page_size=$("#txtPageNum").val();
	var queryCallBack=function(reqInfos,callResult){
		if(reqInfos!=null){
			$.dialog.tips("查询成功...");
			ui_addReqInfo(reqInfos.content.result.list);
			var htmlMsg2=OutPageListAjax(page_size,page_current, reqInfos.content.result.total,  pageChangeCallback, page_interval);
			$("#PageContent").html(htmlMsg2);
			page_current=1;
		}
	}
	listReqInfos(queryCallBack);
}

function pageChangeCallback(pageid){
		page_current=pageid;
		queryGrid();
}

function listReqInfos(callBackList){
	var head={
		"service_name":"cn.dy.workatten.service.ScheduleCfgService",
		"operation_name":"queryScheduleCfgByPage"
	}
	var param={
		"schedule_type": $("#schedule_type").val(),
		"schedule_name": $("#schedule_name").val(),
		"pageNum": page_current,
      	"pageSize": page_size
	}

	var myCallBack=function(data,callResult){
	if(callBackList){
		callBackList(data,callResult);
		}
	}
	var options={
		 "handleError": false,
	      "showProgressBar":false,
	      "timeout":60000*10
	  }
	$.ServiceAgent.JSONInvoke(head,param,myCallBack,options);
}

function obj2Str(obj) {
  return JSON.stringify(obj).replace(/"/g, "'");
}

function goDetails(item) {
	window.location.href = "details.jsp?id="+ item.id;
}

function goEdit(item) {
	window.location.href = "edit.jsp?id="+ item.id;
}

function ui_addReqInfo(data){
var tableTh = "<tr>"
	+ "<th width=\"10%\">序号</th>"
	+ "<th width=\"10%\">类别</th>"
	+ "<th width=\"10%\">班次名称</th>"
	+ "<th width=\"10%\">工时</th>"
	+ "<th width=\"10%\">系数</th>"
	+ "<th width=\"10%\">备注</th>"
	+ "<th width=\"10%\">操作</th>"
+ "</tr>";
$("#resultgrid").html(tableTh);
	for(var i=0;i<data.length;i++){
			var reqInfo=data[i];
			var reqInfoStr = obj2Str(reqInfo);

			var schType = "";
			if(reqInfo.schedule_type == "0"){
				schType = "工作日";
			} else if (reqInfo.schedule_type == "1") {
				schType = "连假周末";
			} else if (reqInfo.schedule_type == "2") {
				schType = "法定节假日";
			} else if (reqInfo.schedule_type == "3") {
				schType = "春节";
			} else if (reqInfo.schedule_type == "4") {
				schType = "周末";
			}

			var htmlMsg="<tr>"
			+"<td align=\"center\">"+((page_current-1)*page_size + i + 1)+"</td>"
			+"<td align=\"center\">"+schType+"</td>"
			+"<td align=\"center\">"+reqInfo.schedule_name+"</td>"
			+"<td align=\"center\">"+reqInfo.man_hour+"</td>"
			+"<td align=\"center\">"+reqInfo.ratio+"</td>"
			+"<td align=\"center\">"+(reqInfo.remark==null?"":reqInfo.remark)+"</td>"
			+"<td align=\"center\" class=\"choose\">"
			+"<span style=\"margin-right: 20px\" class=\"choose\" onclick=\"goDetails(" + reqInfoStr + ")\">查看</span>"
			+"<span class=\"choose\" onclick=\"goEdit(" + reqInfoStr + ")\">修改</span>"
			+"</td></tr>";
			$("#resultgrid").append(htmlMsg);

		}
}


$(document).ready(function(){
	queryGrid();
});
</script>

</head>
<body class="mainbody">
			 <!-- 导航栏 -->
			<div class="location">
				<a href="javascript:;" class="home"><i></i><span>班次管理</span>
				</a>
			</div>

			<!-- 操作栏 -->
			<div class="toolbar-wrap">
				<div id="floatHead" class="toolbar">
					<div class="r-list" style="float: none">
						<!--<span class="operation_time">类别选择:</span>-->
						<div class="rule-single-select"
							style="float: left; margin-left: 5px;">
							<select id="schedule_type" style="width: 150px;">
								<option value="">
									请选择类别
								</option>
								<option value="0">
									工作日
								</option>
								<option value="1">
									连假周末
								</option>
								<option value="2">
									法定节假日
								</option>
								<option value="3">
									春节
								</option>
								<option value="4">
									周末
								</option>
							</select>
						</div>
						<input type="text" id="schedule_name" class="keyword date" placeholder="班次名称">
						<!-- <a id="lbtnSearch" class="reset" onclick="queryGrid();"><span>查询</span></a> -->
						<a id="lbtnSearch" class="btn-search" onclick="queryGrid();"><i></i><span>查询</span></a>
					</div>
				</div>
			</div>
		<!--查询结果列表-->
		<table width="100%" border="0" cellpadding="0" cellpadding="0" class="ltable" id="resultgrid">
			<tr>
				<th width="10%">序号</th>
				<th width="10%">类别</th>
				<th width="10%">班次名称</th>
				<th width="10%">工时</th>
				<th width="10%">系数</th>
				<th width="10%">备注</th>
				<th width="10%">操作</th>
			</tr>
		</table>

		<!--内容底部-->
		<div class="line30"></div>
		<div class="pagelist">
			<div class="l-btns">
				<span>显示</span>
				<input type="text" name="txtPageNum" value="10"
				onchange="javascript:setTimeout(&#39;__doPostBack(\&#39;txtPageNum\&#39;,\&#39;\&#39;)&#39;, 0)"
				onkeypress="if (WebForm_TextBoxKeyHandler(event) == false) return false;"
						id="txtPageNum" class="pagenum"
						onkeydown="return checkNumber(event);"/>
				<span>条/页</span>
			</div>
			<div id="PageContent" class="default">
			</div>
		</div>

</body>
</html>
